﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using System.Data;
using System.Data.SqlClient;
using CustomerManagement.Header;
namespace CustomerManagement.BO
{
    class NhomSanPhamBO
    {
        public string getLinhVuc(SqlConnection conn, ref DataTable tbLinhVuc)
        {
            String cmd = "Select distinct " + CustomerHeader.NSP_LINH_VUC
                + " From " + CustomerHeader.TB_NHOM_SP;
            CommonDO cmDO = new CommonDO();
            return cmDO.getTable(conn, ref tbLinhVuc, cmd);       
        }
        public String getNhomSanPhamAll(SqlConnection conn, ref DataTable tbDataGrid)
        {
            String cmd = "Select * "
                + " From " + CustomerHeader.TB_NHOM_SP;
            CommonDO cmDO = new CommonDO();
            return cmDO.getTable(conn, ref tbDataGrid, cmd);       
            
        }
        public String InsertRecord(SqlConnection conn, StructNhomSanPham stNSP)
        {
            String cmd = "INSERT INTO ToHopVanSon (NSPID, LinhVuc, TenNhom, PhanNhom, GhiChu) VALUES (";
            cmd = String.Concat(cmd, stNSP.sNSPID, ",");
            cmd = String.Concat(cmd, stNSP.sLinhVuc, ",");
            cmd = String.Concat(cmd, stNSP.sTenNhom, ",");
            cmd = String.Concat(cmd, stNSP.sPhanNhom, ",");
            cmd = String.Concat(cmd, stNSP.sGhiChu);

            CommonDO cmDO = new CommonDO();
            return cmDO.ExcecuteQuery(conn, cmd);
        }

    }
}
